package top.program.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import top.program.dao.StudentMapper;
import top.program.dao.TeacherMapper;
import top.program.entity.Student;
import top.program.entity.Teacher;

@Service("studentServiceImpl")
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private TeacherService teacherService;

    @Transactional
    @Override
    public int createStudent(Student student) {
        studentMapper.insertSelective(student);

        Teacher teacher = new Teacher();
        teacher.setTid(1234);
        teacher.setTname("老王123214");

        teacherService.createTeacher(teacher);
        return 0;
    }
}
